package com.xw.bo.ks.controller;


import com.xw.bo.ks.entity.CacheControllerInfo;
import com.xw.bo.ks.entity.base.BoPage;
import com.xw.bo.ks.entity.bean.CacheControllerInfoReq;
import com.xw.bo.ks.service.CacheControllerInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author： xw ftl auto
 * @create： 2024-06-06 17:49:45
 */
@RestController
@RequestMapping("/cacheControllerInfo")
public class CacheControllerInfoController {

    @Resource
    private CacheControllerInfoService cacheControllerInfoService;

    /**
     * 简单的分页查询
     */
    @GetMapping("/page/{pageNumber}/{pageSize}")
    public BoPage<CacheControllerInfo> pageCacheControllerInfoList(@PathVariable Integer pageNumber, @PathVariable Integer pageSize) {
        return cacheControllerInfoService.pageSampleCacheControllerInfo(pageNumber,pageSize);
    }

    /**
     * 按条件分页查询
     */
    @PostMapping("/pageReq")
    public BoPage<CacheControllerInfo> pageReq(@RequestBody CacheControllerInfoReq cacheControllerInfoReq) {
        return cacheControllerInfoService.pageCacheControllerInfoMapper(cacheControllerInfoReq);
    }

    /**
     * 通过id查询详情
     */
    @GetMapping("/{id}")
    public CacheControllerInfo getCacheControllerInfoById(@PathVariable Long id) {
        return cacheControllerInfoService.getById(id);
    }

    /**
     * 新增
     */
    @PostMapping
    public boolean createCacheControllerInfo(@RequestBody CacheControllerInfo cacheControllerInfo) {
        cacheControllerInfoService.saveOrUpdateById(cacheControllerInfo);
        return true;
    }

    /**
     * 通过id修改
     */
    @PostMapping("/put/{id}")
    public boolean updateCacheControllerInfo(@PathVariable Integer id, @RequestBody CacheControllerInfo cacheControllerInfo) {
        cacheControllerInfo.setId(id);
        return cacheControllerInfoService.updateById(cacheControllerInfo);
    }

    /**
     * 删除
     */
    @GetMapping("/delete/{id}")
    public void deleteCacheControllerInfo(@PathVariable Long id) {
        cacheControllerInfoService.removeById(id);
    }

}
